#!/usr/bin/python
# -*- coding: utf-8 -*-
# @author: 高建平
# @description: 
#


from fastapi import FastAPI
from loguru import logger
from app.middleware.cors_domain import middleware as cors_domain_middleware
from app.middleware.logging_middleware import middleware as loggin_middleware
from app.middleware.catch_exceptions_middleware import middleware as catch_exceptions_middleware
from config.bootstrap import settings


def register(app:FastAPI):
    app.debug = settings.DEBUG
    app.title = settings.NAME

    cors_domain_middleware(app)
    catch_exceptions_middleware(app)
    loggin_middleware(app)
    
    # This hook ensures that a connection is opened to handle any queries
    # generated by the request.
    # @app.on_event("startup")
    # def startup():
    #     db.connect()

    # This hook ensures that the connection is closed when we've finished
    # processing the request.
    @app.on_event("shutdown")
    def shutdown():
        pass
            